package com.hd.service.impl;

import java.util.Date;

import org.springframework.dao.DataAccessException;

import com.hd.common.DataPage;
import com.hd.persistence.dao.AcceptTreatmentCaseDao;
import com.hd.persistence.dao.ActualizeProjectDao;
import com.hd.persistence.dao.AppraisalDao;
import com.hd.persistence.dao.AssignRecordDao;
import com.hd.persistence.dao.PartUsageDao;
import com.hd.persistence.dao.RepairReportDao;
import com.hd.persistence.dao.ReturnRecordDao;
import com.hd.persistence.model.AcceptTreatmentCase;
import com.hd.persistence.model.ActualizeProject;
import com.hd.persistence.model.Appraisal;
import com.hd.persistence.model.AssignRecord;
import com.hd.persistence.model.PartUsage;
import com.hd.persistence.model.RepairReport;
import com.hd.persistence.model.ReturnRecord;
import com.hd.service.RepairManager;
import com.hd.utils.HdException;

public class RepairManagerImpl implements RepairManager {
	private AcceptTreatmentCaseDao acceptTreatmentCaseDao;
	private ActualizeProjectDao actualizeProjectDao;
	private AppraisalDao appraisalDao;
	private AssignRecordDao assignRecordDao;
	private PartUsageDao partUsageDao;
	private RepairReportDao repairReportDao;
	private ReturnRecordDao returnRecordDao;
	
	////////////////////受理单////////////////////
	
	public void saveAcceptTreatmentCase(AcceptTreatmentCase acceptTreatmentCase) throws HdException {
		try {
			acceptTreatmentCaseDao.save(acceptTreatmentCase);
		} catch (DataAccessException e) {
			throw new HdException(e.getMessage());
		}
	}
	
	public void deleteAcceptTreatmentCase(Long acceptTreatmentCaseId) throws HdException {
		try {
			acceptTreatmentCaseDao.removeById(acceptTreatmentCaseId);
		} catch (DataAccessException e) {
			throw new HdException(e.getMessage());
		}
	}
	
	public AcceptTreatmentCase getAcceptTreatmentCase(Long acceptTreatmentCaseId) throws HdException {
		try {
			return acceptTreatmentCaseDao.get(acceptTreatmentCaseId);
		} catch (DataAccessException e) {
			throw new HdException(e.getMessage());
		}
	}
	
	public DataPage<AcceptTreatmentCase> pageQueryAcceptTreatmentCases(String unitName, String acceptTreatmenter, Date acceptTreatmentTime, int pageNo, int pageSize) throws HdException {
		try {
			return acceptTreatmentCaseDao.pageQueryAcceptTreatmentCases(unitName, acceptTreatmenter, acceptTreatmentTime, pageNo, pageSize);
		} catch (DataAccessException e) {
			throw new HdException(e.getMessage());
		}
	}
	
	////////////////////实施项目////////////////////
	
	public void saveActualizeProject(ActualizeProject actualizeProject) throws HdException {
		try {
			actualizeProjectDao.save(actualizeProject);
		} catch (DataAccessException e) {
			throw new HdException(e.getMessage());
		}
	}
	
	public void deleteActualizeProject(Long actualizeProjectId) throws HdException {
		try {
			actualizeProjectDao.removeById(actualizeProjectId);
		} catch (DataAccessException e) {
			throw new HdException(e.getMessage());
		}
	}
	
	public ActualizeProject getActualizeProject(Long actualizeProjectId) throws HdException {
		try {
			return actualizeProjectDao.get(actualizeProjectId);
		} catch (DataAccessException e) {
			throw new HdException(e.getMessage());
		}
	}
	
	public DataPage<ActualizeProject> pageQueryActualizeProjects(int pageNo, int pageSize) throws HdException {
		try {
			return actualizeProjectDao.pageQueryActualizeProjects(pageNo, pageSize);
		} catch (DataAccessException e) {
			throw new HdException(e.getMessage());
		}
	}
	
	////////////////////客户评价////////////////////
	
	public void saveAppraisal(Appraisal appraisal) throws HdException {
		try {
			appraisalDao.save(appraisal);
		} catch (DataAccessException e) {
			throw new HdException(e.getMessage());
		}
	}
	
	public void deleteAppraisal(Long appraisalId) throws HdException {
		try {
			appraisalDao.removeById(appraisalId);
		} catch (DataAccessException e) {
			throw new HdException(e.getMessage());
		}
	}
	
	public Appraisal getAppraisal(Long appraisalId) throws HdException {
		try {
			return appraisalDao.get(appraisalId);
		} catch (DataAccessException e) {
			throw new HdException(e.getMessage());
		}
	}
	
	public DataPage<Appraisal> pageQueryAppraisals(int pageNo, int pageSize) throws HdException {
		try {
			return appraisalDao.pageQueryAppraisals(pageNo, pageSize);
		} catch (DataAccessException e) {
			throw new HdException(e.getMessage());
		}
	}
	
	////////////////////调派单////////////////////
	
	public void saveAssignRecord(AssignRecord assignRecord) throws HdException {
		try {
			assignRecordDao.save(assignRecord);
		} catch (DataAccessException e) {
			throw new HdException(e.getMessage());
		}
	}
	
	public void deleteAssignRecord(Long assignRecordId) throws HdException {
		try {
			assignRecordDao.removeById(assignRecordId);
		} catch (DataAccessException e) {
			throw new HdException(e.getMessage());
		}
	}
	
	public AssignRecord getAssignRecord(Long assignRecordId) throws HdException {
		try {
			return assignRecordDao.get(assignRecordId);
		} catch (DataAccessException e) {
			throw new HdException(e.getMessage());
		}
	}
	
	public DataPage<AssignRecord> pageQuryAssignRecords(int pageNo, int pageSize) throws HdException {
		try {
			return assignRecordDao.pageQueryAssignRecords(pageNo, pageSize);
		} catch (DataAccessException e) {
			throw new HdException(e.getMessage());
		}
	}
	
	public DataPage<AssignRecord> pageQueryAssignRecords(String unitName, String unitForShort, String machineModel, String repairman, Date workday, int pageNo, int pageSize) throws HdException {
		try {
			return assignRecordDao.pageQueryAssignRecords(unitName, unitForShort, machineModel, repairman, workday, pageNo, pageSize);
		} catch (DataAccessException e) {
			throw new HdException(e.getMessage());
		}
	}
	
	////////////////////零件使用////////////////////
	
	public void savePartUsage(PartUsage partUsage) throws HdException {
		try {
			partUsageDao.save(partUsage);
		} catch (DataAccessException e) {
			throw new HdException(e.getMessage());
		}
	}
	
	public void deletePartUsage(Long partUsageId) throws HdException {
		try {
			partUsageDao.removeById(partUsageId);
		} catch (DataAccessException e) {
			throw new HdException(e.getMessage());
		}
	}
	
	public PartUsage getPartUsage(Long partUsageId) throws HdException {
		try {
			return partUsageDao.get(partUsageId);
		} catch (DataAccessException e) {
			throw new HdException(e.getMessage());
		}
	}
	
	public DataPage<PartUsage> pageQueryPartUsages(int pageNo, int pageSize) throws HdException {
		try {
			return partUsageDao.pageQueryPartUsages(pageNo, pageSize);
		} catch (DataAccessException e) {
			throw new HdException(e.getMessage());
		}
	}
	
	////////////////////维修报告////////////////////
	
	public void saveRepairReport(RepairReport repairReport) throws HdException {
		try {
			repairReportDao.saveRepairReport(repairReport);
		} catch (DataAccessException e) {
			throw new HdException(e.getMessage());
		}
	}
	
	public void deleteRepairReport(Long repairReportId) throws HdException {
		try {
			repairReportDao.removeById(repairReportId);
		} catch (DataAccessException e) {
			throw new HdException(e.getMessage());
		}
	}
	
	public RepairReport getRepairReport(Long repairReportId) throws HdException {
		try {
			return repairReportDao.get(repairReportId);
		} catch (DataAccessException e) {
			throw new HdException(e.getMessage());
		}
	}
	
	public DataPage<RepairReport> pageQueryRepairReports(int pageNo, int pageSize) throws HdException {
		try {
			return repairReportDao.pageQueryRepairReports(pageNo, pageSize);
		} catch (DataAccessException e) {
			throw new HdException(e.getMessage());
		}
	}
	
	public DataPage<RepairReport> pageQueryRepairReports(Date repairDate, String repairman, String unitName, Integer category, String machineNo, int pageNo, int pageSize) throws HdException {
		try {
			return repairReportDao.pageQueryRepairReports(repairDate, repairman, unitName, category, machineNo, pageNo, pageSize);
		} catch (DataAccessException e) {
			throw new HdException(e.getMessage());
		}
	}
	
	////////////////////回访单////////////////////
	
	public void saveReturnRecord(ReturnRecord returnRecord) throws HdException {
		try {
			returnRecordDao.saveReturnRecord(returnRecord);
		} catch (DataAccessException e) {
			throw new HdException(e.getMessage());
		}
	}
	
	public void deleteReturnRecord(Long returnRecordId) throws HdException {
		try {
			returnRecordDao.removeById(returnRecordId);
		} catch (DataAccessException e) {
			throw new HdException(e.getMessage());
		}
	}
	
	public ReturnRecord getReturnRecord(Long returnRecordId) throws HdException {
		try {
			return returnRecordDao.get(returnRecordId);
		} catch (DataAccessException e) {
			throw new HdException(e.getMessage());
		}
	}
	
	public DataPage<ReturnRecord> pageQueryReturnRecords(int pageNo, int pageSize) throws HdException {
		try {
			return returnRecordDao.pageQueryReturnRecords(pageNo, pageSize);
		} catch (DataAccessException e) {
			throw new HdException(e.getMessage());
		}
	}
	
	public DataPage<ReturnRecord> pageQueryReturnRecords(String unitName, String machineModel, String thisTimeRepairman, Date thisTimeRepairDate, int pageNo, int pageSize) throws HdException {
		try {
			return returnRecordDao.pageQueryReturnRecords(unitName, machineModel, thisTimeRepairman, thisTimeRepairDate, pageNo, pageSize);
		} catch (DataAccessException e) {
			throw new HdException(e.getMessage());
		}
	}
	
	////////////////////gettet、setter////////////////////
	
	public AcceptTreatmentCaseDao getAcceptTreatmentCaseDao() {
		return acceptTreatmentCaseDao;
	}
	public void setAcceptTreatmentCaseDao(
			AcceptTreatmentCaseDao acceptTreatmentCaseDao) {
		this.acceptTreatmentCaseDao = acceptTreatmentCaseDao;
	}
	public ActualizeProjectDao getActualizeProjectDao() {
		return actualizeProjectDao;
	}
	public void setActualizeProjectDao(ActualizeProjectDao actualizeProjectDao) {
		this.actualizeProjectDao = actualizeProjectDao;
	}
	public AppraisalDao getAppraisalDao() {
		return appraisalDao;
	}
	public void setAppraisalDao(AppraisalDao appraisalDao) {
		this.appraisalDao = appraisalDao;
	}
	public AssignRecordDao getAssignRecordDao() {
		return assignRecordDao;
	}
	public void setAssignRecordDao(AssignRecordDao assignRecordDao) {
		this.assignRecordDao = assignRecordDao;
	}
	public PartUsageDao getPartUsageDao() {
		return partUsageDao;
	}
	public void setPartUsageDao(PartUsageDao partUsageDao) {
		this.partUsageDao = partUsageDao;
	}
	public RepairReportDao getRepairReportDao() {
		return repairReportDao;
	}
	public void setRepairReportDao(RepairReportDao repairReportDao) {
		this.repairReportDao = repairReportDao;
	}
	public ReturnRecordDao getReturnRecordDao() {
		return returnRecordDao;
	}
	public void setReturnRecordDao(ReturnRecordDao returnRecordDao) {
		this.returnRecordDao = returnRecordDao;
	}
	
	
}
